
package cn.edu.scau.cmi.hombio.domain;

import java.io.Serializable;

import java.lang.StringBuilder;

import java.util.LinkedHashSet;
import java.util.Set;

import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;

import org.codehaus.jackson.annotate.JsonIgnore;

import javax.xml.bind.annotation.*;

import javax.persistence.*;

/**
 */

@Entity
@NamedQueries({
		@NamedQuery(name = "findAllMedicines", query = "select myMedicine from Medicine myMedicine"),
		@NamedQuery(name = "findMedicineByCompany", query = "select myMedicine from Medicine myMedicine where myMedicine.company = ?1"),
		@NamedQuery(name = "findMedicineByCompanyContaining", query = "select myMedicine from Medicine myMedicine where myMedicine.company like ?1"),
		@NamedQuery(name = "findMedicineById", query = "select myMedicine from Medicine myMedicine where myMedicine.id = ?1"),
		@NamedQuery(name = "findMedicineByMemo", query = "select myMedicine from Medicine myMedicine where myMedicine.memo = ?1"),
		@NamedQuery(name = "findMedicineByMemoContaining", query = "select myMedicine from Medicine myMedicine where myMedicine.memo like ?1"),
		@NamedQuery(name = "findMedicineByName", query = "select myMedicine from Medicine myMedicine where myMedicine.name = ?1"),
		@NamedQuery(name = "findMedicineByNameContaining", query = "select myMedicine from Medicine myMedicine where myMedicine.name like ?1"),
		@NamedQuery(name = "findMedicineByNumber", query = "select myMedicine from Medicine myMedicine where myMedicine.number = ?1"),
		@NamedQuery(name = "findMedicineByNumberContaining", query = "select myMedicine from Medicine myMedicine where myMedicine.number like ?1"),
		@NamedQuery(name = "findMedicineByPhone", query = "select myMedicine from Medicine myMedicine where myMedicine.phone = ?1"),
		@NamedQuery(name = "findMedicineByPhoneContaining", query = "select myMedicine from Medicine myMedicine where myMedicine.phone like ?1"),
		@NamedQuery(name = "findMedicineByPrimaryKey", query = "select myMedicine from Medicine myMedicine where myMedicine.id = ?1"),
		@NamedQuery(name = "findMedicineByQuantityPerBox", query = "select myMedicine from Medicine myMedicine where myMedicine.quantityPerBox = ?1"),
		@NamedQuery(name = "findMedicineByQuantityPerCase", query = "select myMedicine from Medicine myMedicine where myMedicine.quantityPerCase = ?1") })

@Table(catalog = "pig", name = "medicine")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(namespace = "pigRs/cn/edu/scau/cmi/hombio/domain", name = "Medicine")
@XmlRootElement(namespace = "pigRs/cn/edu/scau/cmi/hombio/domain")
public class Medicine implements Serializable {
	private static final long serialVersionUID = 1L;

	/**
	 */

	@Column(name = "Id", nullable = false)
	@Basic(fetch = FetchType.EAGER)

	@Id @GeneratedValue
	@XmlElement
	Integer id;
	/**
	 */

	@Column(name = "Name", nullable = false)
	@Basic(fetch = FetchType.EAGER)

	@XmlElement
	String name;
	/**
	* ��ҩ����
	* 
	 */

	@Column(name = "Number")
	@Basic(fetch = FetchType.EAGER)

	@XmlElement
	String number;
	/**
	 */

	@Column(name = "Company")
	@Basic(fetch = FetchType.EAGER)

	@XmlElement
	String company;
	/**
	* ����Ǻ�װ����װ������
	* 
	 */

	@Column(name = "QuantityPerCase")
	@Basic(fetch = FetchType.EAGER)

	@XmlElement
	Integer quantityPerCase;
	/**
	 */

	@Column(name = "QuantityPerBox")
	@Basic(fetch = FetchType.EAGER)

	@XmlElement
	Integer quantityPerBox;
	/**
	* ҩƷ��˾����ϵ�绰
	* 
	 */

	@Column(name = "Phone")
	@Basic(fetch = FetchType.EAGER)

	@XmlElement
	String phone;
	/**
	 */

	@Column(name = "Memo")
	@Basic(fetch = FetchType.EAGER)

	@XmlElement
	String memo;

	/**
	 */
	@OneToMany(mappedBy = "medicineByReportMedicineId", cascade = { CascadeType.REMOVE }, fetch = FetchType.LAZY)

	
	java.util.Set<cn.edu.scau.cmi.hombio.domain.PreventionType> preventionTypesForReportMedicineId;
	/**
	 */
	@OneToMany(mappedBy = "medicine", cascade = { CascadeType.REMOVE }, fetch = FetchType.LAZY)

	
	java.util.Set<cn.edu.scau.cmi.hombio.domain.MedicineStorageDetail> medicineStorageDetails;
	/**
	 */
	@OneToMany(mappedBy = "medicine", cascade = { CascadeType.REMOVE }, fetch = FetchType.LAZY)

	
	java.util.Set<cn.edu.scau.cmi.hombio.domain.MedicineSupplier> medicineSuppliers;
	/**
	 */
	@OneToMany(mappedBy = "medicine", cascade = { CascadeType.REMOVE }, fetch = FetchType.LAZY)

	
	java.util.Set<cn.edu.scau.cmi.hombio.domain.CureTaskMedicine> cureTaskMedicines;
	/**
	 */
	@OneToMany(mappedBy = "medicineByReportMedicineId", cascade = { CascadeType.REMOVE }, fetch = FetchType.LAZY)

	
	java.util.Set<cn.edu.scau.cmi.hombio.domain.PreventionType> preventionTypesForMedicineId;
	/**
	 */
	@OneToMany(mappedBy = "medicine", cascade = { CascadeType.REMOVE }, fetch = FetchType.LAZY)

	
	java.util.Set<cn.edu.scau.cmi.hombio.domain.CureMedicine> cureMedicines;
	/**
	 */
	@OneToMany(mappedBy = "medicine", cascade = { CascadeType.REMOVE }, fetch = FetchType.LAZY)

	
	java.util.Set<cn.edu.scau.cmi.hombio.domain.MedicineTakeDetail> medicineTakeDetails;

	/**
	 */
	public void setId(Integer id) {
		this.id = id;
	}

	/**
	 */
	public Integer getId() {
		return this.id;
	}

	/**
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 */
	public String getName() {
		return this.name;
	}

	/**
	* ��ҩ����
	* 
	 */
	public void setNumber(String number) {
		this.number = number;
	}

	/**
	* ��ҩ����
	* 
	 */
	public String getNumber() {
		return this.number;
	}

	/**
	 */
	public void setCompany(String company) {
		this.company = company;
	}

	/**
	 */
	public String getCompany() {
		return this.company;
	}

	/**
	* ����Ǻ�װ����װ������
	* 
	 */
	public void setQuantityPerCase(Integer quantityPerCase) {
		this.quantityPerCase = quantityPerCase;
	}

	/**
	* ����Ǻ�װ����װ������
	* 
	 */
	public Integer getQuantityPerCase() {
		return this.quantityPerCase;
	}

	/**
	 */
	public void setQuantityPerBox(Integer quantityPerBox) {
		this.quantityPerBox = quantityPerBox;
	}

	/**
	 */
	public Integer getQuantityPerBox() {
		return this.quantityPerBox;
	}

	/**
	* ҩƷ��˾����ϵ�绰
	* 
	 */
	public void setPhone(String phone) {
		this.phone = phone;
	}

	/**
	* ҩƷ��˾����ϵ�绰
	* 
	 */
	public String getPhone() {
		return this.phone;
	}

	/**
	 */
	public void setMemo(String memo) {
		this.memo = memo;
	}

	/**
	 */
	public String getMemo() {
		return this.memo;
	}

	/**
	 */
	public void setPreventionTypesForReportMedicineId(Set<PreventionType> preventionTypesForReportMedicineId) {
		this.preventionTypesForReportMedicineId = preventionTypesForReportMedicineId;
	}

	/**
	 */
	@JsonIgnore
	public Set<PreventionType> getPreventionTypesForReportMedicineId() {
		if (preventionTypesForReportMedicineId == null) {
			preventionTypesForReportMedicineId = new java.util.LinkedHashSet<cn.edu.scau.cmi.hombio.domain.PreventionType>();
		}
		return preventionTypesForReportMedicineId;
	}

	/**
	 */
	public void setMedicineStorageDetails(Set<MedicineStorageDetail> medicineStorageDetails) {
		this.medicineStorageDetails = medicineStorageDetails;
	}

	/**
	 */
	@JsonIgnore
	public Set<MedicineStorageDetail> getMedicineStorageDetails() {
		if (medicineStorageDetails == null) {
			medicineStorageDetails = new java.util.LinkedHashSet<cn.edu.scau.cmi.hombio.domain.MedicineStorageDetail>();
		}
		return medicineStorageDetails;
	}

	/**
	 */
	public void setMedicineSuppliers(Set<MedicineSupplier> medicineSuppliers) {
		this.medicineSuppliers = medicineSuppliers;
	}

	/**
	 */
	@JsonIgnore
	public Set<MedicineSupplier> getMedicineSuppliers() {
		if (medicineSuppliers == null) {
			medicineSuppliers = new java.util.LinkedHashSet<cn.edu.scau.cmi.hombio.domain.MedicineSupplier>();
		}
		return medicineSuppliers;
	}

	/**
	 */
	public void setCureTaskMedicines(Set<CureTaskMedicine> cureTaskMedicines) {
		this.cureTaskMedicines = cureTaskMedicines;
	}

	/**
	 */
	@JsonIgnore
	public Set<CureTaskMedicine> getCureTaskMedicines() {
		if (cureTaskMedicines == null) {
			cureTaskMedicines = new java.util.LinkedHashSet<cn.edu.scau.cmi.hombio.domain.CureTaskMedicine>();
		}
		return cureTaskMedicines;
	}

	/**
	 */
	public void setPreventionTypesForMedicineId(Set<PreventionType> preventionTypesForMedicineId) {
		this.preventionTypesForMedicineId = preventionTypesForMedicineId;
	}

	/**
	 */
	@JsonIgnore
	public Set<PreventionType> getPreventionTypesForMedicineId() {
		if (preventionTypesForMedicineId == null) {
			preventionTypesForMedicineId = new java.util.LinkedHashSet<cn.edu.scau.cmi.hombio.domain.PreventionType>();
		}
		return preventionTypesForMedicineId;
	}

	/**
	 */
	public void setCureMedicines(Set<CureMedicine> cureMedicines) {
		this.cureMedicines = cureMedicines;
	}

	/**
	 */
	@JsonIgnore
	public Set<CureMedicine> getCureMedicines() {
		if (cureMedicines == null) {
			cureMedicines = new java.util.LinkedHashSet<cn.edu.scau.cmi.hombio.domain.CureMedicine>();
		}
		return cureMedicines;
	}

	/**
	 */
	public void setMedicineTakeDetails(Set<MedicineTakeDetail> medicineTakeDetails) {
		this.medicineTakeDetails = medicineTakeDetails;
	}

	/**
	 */
	@JsonIgnore
	public Set<MedicineTakeDetail> getMedicineTakeDetails() {
		if (medicineTakeDetails == null) {
			medicineTakeDetails = new java.util.LinkedHashSet<cn.edu.scau.cmi.hombio.domain.MedicineTakeDetail>();
		}
		return medicineTakeDetails;
	}

	/**
	 */
	public Medicine() {
	}

	/**
	 * Copies the contents of the specified bean into this bean.
	 *
	 */
	public void copy(Medicine that) {
		setId(that.getId());
		setName(that.getName());
		setNumber(that.getNumber());
		setCompany(that.getCompany());
		setQuantityPerCase(that.getQuantityPerCase());
		setQuantityPerBox(that.getQuantityPerBox());
		setPhone(that.getPhone());
		setMemo(that.getMemo());
		setPreventionTypesForReportMedicineId(new java.util.LinkedHashSet<cn.edu.scau.cmi.hombio.domain.PreventionType>(that.getPreventionTypesForReportMedicineId()));
		setMedicineStorageDetails(new java.util.LinkedHashSet<cn.edu.scau.cmi.hombio.domain.MedicineStorageDetail>(that.getMedicineStorageDetails()));
		setMedicineSuppliers(new java.util.LinkedHashSet<cn.edu.scau.cmi.hombio.domain.MedicineSupplier>(that.getMedicineSuppliers()));
		setCureTaskMedicines(new java.util.LinkedHashSet<cn.edu.scau.cmi.hombio.domain.CureTaskMedicine>(that.getCureTaskMedicines()));
		setPreventionTypesForMedicineId(new java.util.LinkedHashSet<cn.edu.scau.cmi.hombio.domain.PreventionType>(that.getPreventionTypesForMedicineId()));
		setCureMedicines(new java.util.LinkedHashSet<cn.edu.scau.cmi.hombio.domain.CureMedicine>(that.getCureMedicines()));
		setMedicineTakeDetails(new java.util.LinkedHashSet<cn.edu.scau.cmi.hombio.domain.MedicineTakeDetail>(that.getMedicineTakeDetails()));
	}

	/**
	 * Returns a textual representation of a bean.
	 *
	 */
	public String toString() {

		StringBuilder buffer = new StringBuilder();

		buffer.append("id=[").append(id).append("] ");
		buffer.append("name=[").append(name).append("] ");
		buffer.append("number=[").append(number).append("] ");
		buffer.append("company=[").append(company).append("] ");
		buffer.append("quantityPerCase=[").append(quantityPerCase).append("] ");
		buffer.append("quantityPerBox=[").append(quantityPerBox).append("] ");
		buffer.append("phone=[").append(phone).append("] ");
		buffer.append("memo=[").append(memo).append("] ");

		return buffer.toString();
	}

	/**
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = (int) (prime * result + ((id == null) ? 0 : id.hashCode()));
		return result;
	}

	/**
	 */
	public boolean equals(Object obj) {
		if (obj == this)
			return true;
		if (!(obj instanceof Medicine))
			return false;
		Medicine equalCheck = (Medicine) obj;
		if ((id == null && equalCheck.id != null) || (id != null && equalCheck.id == null))
			return false;
		if (id != null && !id.equals(equalCheck.id))
			return false;
		return true;
	}
}
